{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[6, 9, 6],\n",
       "       [1, 1, 2],\n",
       "       [8, 7, 3],\n",
       "       [5, 6, 3],\n",
       "       [5, 3, 5],\n",
       "       [8, 8, 2],\n",
       "       [8, 1, 7],\n",
       "       [8, 7, 2],\n",
       "       [1, 2, 9],\n",
       "       [9, 4, 9]])"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "np.random.seed(1)\n",
    "X = np.random.randint(1, 10, size=30)\n",
    "X=X.reshape(-1,3)\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[6, 9, 1],\n",
       "       [1, 1, 0],\n",
       "       [8, 7, 0],\n",
       "       [5, 6, 0],\n",
       "       [5, 3, 1],\n",
       "       [8, 8, 0],\n",
       "       [8, 1, 2],\n",
       "       [8, 7, 0],\n",
       "       [1, 2, 2],\n",
       "       [9, 4, 2]])"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for i in range(10):\n",
    "    if X[i,2]<=3:\n",
    "        X[i,2] = 0\n",
    "    elif X[i,2]<=6:\n",
    "        X[i,2] = 1\n",
    "    else:\n",
    "        X[i,2] = 2\n",
    "X"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 0 0 0 1 0 2 0 2 2]\n"
     ]
    }
   ],
   "source": [
    "Y_train=X[...,2]\n",
    "X_train=X[:,[0,1]]\n",
    "print(Y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([[1, 1],\n",
       "        [8, 7],\n",
       "        [5, 6],\n",
       "        [8, 8],\n",
       "        [8, 7]]),\n",
       " array([[6, 9],\n",
       "        [5, 3]]),\n",
       " array([[8, 1],\n",
       "        [1, 2],\n",
       "        [9, 4]]))"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = []\n",
    "b = []\n",
    "c = []\n",
    "for i in range(10):\n",
    "    if Y_train[i]==0:\n",
    "        a.append(X_train[i])\n",
    "    elif Y_train[i]==1:\n",
    "        b.append(X_train[i])\n",
    "    else:\n",
    "        c.append(X_train[i])\n",
    "a,b,c=np.array(a),np.array(b),np.array(c)\n",
    "a,b,c"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
